/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       perspectivecamera.h
 * Author:     karooolek
 * Created on: 2009-04-03
 *
 **********************************************************************************************************************/

#ifndef PERSPECTIVECAMERA_H_
#define PERSPECTIVECAMERA_H_

#include "camera.h"
#include "glee.h"

namespace mGameEngine
{
namespace Graphics
{

/**
 * Perspective projection camera.
 */
class PerspectiveCamera: public Camera
{
protected:
    /**
     * Field of view.
     */
    float _fov;

public:
    /**
     * Create perspective projetction camera with specified field of view.
     * @param fov field of view in radians.
     * @param ratio aspect ratio.
     * @param autoRatio automatic aspect ratio calculation.
     * @param nearClip near clipping plane.
     * @param farClip far clipping plane.
     */
    PerspectiveCamera(float fov = M_PI_2,
            float ratio = 1.0f, bool autoRatio = true,
            float nearClip = 0.01f, float farClip = 1000.0f);

    /**
     * Destroy perspective projection camera.
     */
    virtual ~PerspectiveCamera();

    /**
     * Get field of view.
     * @return field of view in radians.
     */
    float getFieldOfView() const
    {
        return _fov;
    }

    /**
     * Set field of view.
     * @param fov field of view in radians.
     */
    void setFieldOfView(float fov)
    {
        _fov = fov;
    }

    /**
     * Test if sphere is visible in camera.
     * @param sphere sphere in camera coordinates.
     * @return true if sphere is all or partially visible, false otherwise
     */
    virtual bool isInCamera(const Sphere &sphere) const;

    /**
     * Calculate relative projected sphere size.
     * @param sphere sphere in camera coordinates.
     * @return projected sphere size relative to fov.
     */
    virtual float getProjectedSize(const Sphere &sphere) const;

    /**
     * Use perspective projection camera as active.
     */
    void use() const;
};

}
}

#endif // PERSPECTIVECAMERA_H_
